﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CourseManage.aspx.cs" Inherits="CMS.Presentation.CourseManage"
    MasterPageFile="~/Site.master" %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript">
        $().ready(function () {
            $("#SearchFieldset").validate({
                rules:
        {
            CourseNameTextBox: {
                maxlength: 5
            }
        }
            });
        });
    </script>
<%--    <script type="text/javascript">
        function ClientValidation(source, arguments) {
            var coursename = document.getElementById("CourseNameTextBox");
            var customvalidation = document.getElementById("SearchCustomValidator");
            var regexPatten = /^[a-zA-Z]+$/;
//            if (coursename.value == "") {
//                arguments.IsValid = false;
//                customvalidation.innerText = "Not Null";
//            }
            if (coursename.value.length > 10) {
                arguments.IsValid = false;
                customvalidation.innerText = "CourseName too long";
            }
//            else if (!regexPatten.exec(coursename.value)) {
//                arguments.IsValid = false;
//                customvalidation.innerText = "Please input correct CourseName";
//            }
        }
    </script>--%>
    <div>
        <fieldset id="SearchFieldset" runat="server">
            <legend>Search Course</legend>
            <table style="width: 90%;">
                <tr>
                    <td class="style2">
                        <asp:Label ID="CourseNameLabel" runat="server" Text="Course Name"></asp:Label>&nbsp;&nbsp;
                        <asp:TextBox ID="CourseNameTextBox" runat="server" ClientIDMode="Static"></asp:TextBox>
                    </td>
                    <td class="style3">
                        <asp:Label ID="StatusLabel" runat="server" Text="Course Status"></asp:Label>
                        <asp:RadioButtonList ID="StatusRadioButtonList" runat="server" RepeatDirection="Horizontal"
                            RepeatLayout="Flow">
                            <asp:ListItem Value="True" Selected="true">Open</asp:ListItem>
                            <asp:ListItem Value="False">Closed</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                    <td class="style1">
                        <asp:Button ID="SearchButton" runat="server" Text="Search" OnClick="SearchButton_Click" />
                    </td>
                </tr>
            </table>
        </fieldset>
        <fieldset id="ListFieldset" runat="server">
            <legend>Course List</legend>
            <table>
                <tr>
                    <td>
                        <asp:Button ID="CreateCourseButton" runat="server" Text="Create New Course" PostBackUrl="~/SaveCourse.aspx"
                            CausesValidation="False" />
                        &nbsp;&nbsp;
                        <asp:Button ID="ChangeStatusButton" runat="server" Text="Batch Close Course" OnClick="ChangeStatusButton_Click"
                            CausesValidation="False" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="SearchMessageLabel" runat="server" Visible="false" Text="Sorry,no record are found! You Can return to Course Page to Search Again"></asp:Label>
                    </td>
                    <td>
                        <asp:HyperLink ID="ReturnHyperLink" runat="server" Visible="False" NavigateUrl="~/CourseManage.aspx">Course Page</asp:HyperLink>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:GridView ID="CourseListGridView" runat="server" CellPadding="4" ForeColor="#333333"
                            GridLines="None" PagerStyle-HorizontalAlign="Right" AutoGenerateColumns="False"
                            OnRowDeleting="CourseListGridView_RowDeleting" OnRowUpdating="CourseListGridView_RowUpdating"
                            OnRowDataBound="CourseListGridView_RowDataBound" AllowPaging="False">
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            <Columns>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:CheckBox ID="StatusCheckBox" runat="server" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="CourseId">
                                    <ItemTemplate>
                                        <asp:Label ID="CourseIdLabel" runat="server" Text='<%# Bind("CourseId") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="CourseName">
                                    <ItemTemplate>
                                        <asp:Label ID="CourseNameLabel" runat="server" Text='<%# Bind("CourseName") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Teacher">
                                    <ItemTemplate>
                                        <asp:Label ID="TeacherNameLabel" runat="server" Text='<%# Bind("Teacher.TeacherName") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Course Level">
                                    <ItemTemplate>
                                        <asp:Label ID="LevelLabel" runat="server" Text='<%# Bind("Level.LevelName") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Course Status">
                                    <ItemTemplate>
                                        <asp:Label ID="StatusLabel" runat="server" Text='<%# Convert.ToBoolean(Eval("CourseStatus"))?"Open":"Closed" %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Actions">
                                    <ItemTemplate>
                                        <asp:Button ID="UpdateButton" runat="server" Text="Update" CommandName="Update" CausesValidation="False">
                                        </asp:Button>
                                        <asp:Button ID="DeleteButton" runat="server" Text="Delete" CommandName="Delete" CausesValidation="False">
                                        </asp:Button>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <PagerSettings Mode="NumericFirstLast" />
                            <EditRowStyle BackColor="#999999" />
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                            <SortedAscendingCellStyle BackColor="#E9E7E2" />
                            <SortedAscendingHeaderStyle BackColor="#506C8C" />
                            <SortedDescendingCellStyle BackColor="#FFFDF8" />
                            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                            <SortedAscendingCellStyle BackColor="#E9E7E2"></SortedAscendingCellStyle>
                            <SortedAscendingHeaderStyle BackColor="#506C8C"></SortedAscendingHeaderStyle>
                            <SortedDescendingCellStyle BackColor="#FFFDF8"></SortedDescendingCellStyle>
                            <SortedDescendingHeaderStyle BackColor="#6F8DAE"></SortedDescendingHeaderStyle>
                        </asp:GridView>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <asp:LinkButton ID="FirstPageLinkButton" runat="server" Text="<<" CommandName="First"
                            OnClick="PageLinkButton_Click" CausesValidation="false"></asp:LinkButton>
                        &nbsp;&nbsp;
                        <asp:LinkButton ID="PreviousLinkButton" runat="server" Text="&lt; " Visible="true"
                            OnClick="PageLinkButton_Click" CausesValidation="False" CommandName="Previous"></asp:LinkButton>
                        &nbsp;&nbsp;
                        <asp:Label ID="PageLabel" runat="server"></asp:Label>
                        <asp:LinkButton ID="NextLinkButton" runat="server" Text="&gt;" Visible="true" CausesValidation="False"
                            OnClick="PageLinkButton_Click" CommandName="Next"></asp:LinkButton>
                        &nbsp;&nbsp;
                        <asp:LinkButton ID="LastPageLinkButton" runat="server" Text=">>" Visible="true" CausesValidation="false" OnClick="PageLinkButton_Click"
                            CommandName="Last"></asp:LinkButton>
                        &nbsp;&nbsp;
                        <asp:Label ID="ItemLabel" runat="server"></asp:Label>
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>
</asp:Content>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="HeadContent">
    <style type="text/css">
        .style1
        {
            height: 58px;
        }
        .style2
        {
            height: 58px;
            width: 465px;
        }
        .style3
        {
            height: 58px;
            width: 289px;
        }
    </style>
</asp:Content>
